package com.wxy.library.controller;

import com.wxy.library.entity.Book;
import com.wxy.library.service.BookService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@Slf4j
@RestController
@RequestMapping("/book")
public class BookController {
    @Autowired
    private BookService bookService;

    @GetMapping
    public R<List<Book>>getData(){
        List<Book> list = bookService.list(null);
        //log.info(list.toString());
        return R.success(list);
    }
    @GetMapping("/book")
    public R<String>getBookNum(Integer id){
        Book book = bookService.getById(id);
        return R.success(book.getBookNum().toString());
    }
}
